﻿using System;
using System.Collections.Generic;

using SBPweb.Messenger.Clients.Base;

namespace SBPweb.Messenger.Clients.WLM.Contacts
{

    public class ContactManager : Services.Contacts.ContactManagerClient, IAsyncContactManager
    {
        
        #region Constructor logic

        public ContactManager()
            : base()
        {
            base.GetAllContactsCompleted += new System.EventHandler<Services.Contacts.GetAllContactsCompletedEventArgs>(ContactManager_GetAllContactsCompleted);
        }

        #endregion

        #region Events

        public new event EventHandler<ResultedAsyncCompletedEventArgs<List<string>>> GetAllContactsCompleted;

        #endregion

        #region Methods

        public List<string> GetAllContacts()
        {
            throw new NotSupportedException("Please use the Asynchronous methods!");
        }

        #endregion

        #region Event handlers

        private void ContactManager_GetAllContactsCompleted(object sender, Services.Contacts.GetAllContactsCompletedEventArgs e)
        {
            if (this.GetAllContactsCompleted != null)
            {
                this.GetAllContactsCompleted(this, new ResultedAsyncCompletedEventArgs<List<string>>(e.Error, e.Cancelled, e.UserState, new List<string>(e.Result)));
            }
        }

        #endregion

    }

}